{% extends 'admin-v2/layout.html.twig' %}

{% do script(['app/js/article/review/index.js']) %}

{% set menu = 'admin_v2_operation_article_review' %}

{% block main %}

  <form id="review-search-form" class="form-inline well well-sm" action="" method="get" novalidate>

    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{'admin.operation_article.review.form.input.title.placeholer'|trans}}" name="articleTitle" value="{{ app.request.get('articleTitle') }}">
    </div>

    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{'admin.operation_article.review.form.input.author.placeholer'|trans}}" name="author" value="{{ app.request.get('author') }}">
    </div>

    <div class="form-group">
      <input class="form-control" type="text" placeholder="{{'admin:operation_article.review.form.input.content.placeholer'|trans}}" name="contentSearch" value="{{ app.request.get('contentSearch') }}">
    </div>

    <button class="btn btn-primary">{{'form.btn.search'|trans}}</button>
  </form>

  <div id="review-table-container">
    <table class="table table-striped table-hover" id="review-table">
      <thead>
      <tr>
        <th width="4%"><input type="checkbox"  data-role="batch-select"></th>
        <th width="55%">{{'admin.operation_article.review.content_th'|trans}}</th>
        <th width="15%">{{'admin.operation_article.review.author_th'|trans}}</th>
        <th width="8%">{{'内容状态'|trans}}</th>
        <th width="8%">{{'admin.operation_article.review.operation_th'|trans}}</th>
      </tr>
      </thead>
      <tbody>
      {% for review in reviews %}
        {% set author = users[review.userId]|default(null) %}
        {% set article = review.targetType == 'article' ? articles[review.targetId]|default(null) : null %}
        <tr id="review-table-tr-{{review.id}}" data-role="item">
          <td><input type="checkbox" value="{{review.id}}" data-role="batch-item"></td>
          <td>
            <div class="short-long-text">
              <div class="short-text">
                {{ review.content|plain_text(60) }} <span class="text-muted trigger">({{'admin.operation_article.review.expand_td'|trans}})</span>
              </div>
              <div class="long-text">{{ review.content|nl2br }} <span class="text-muted trigger">({{'admin.operation_article.review.collapse_td'|trans}})</span></div>
            </div>
            <div class="mts">
              {% if article %}
                <span class="text-muted mhs text-sm">&raquo;</span>
                <a class="text-success text-sm" href="{{ path('article_detail', {id:article.id}) }}" class="text-success" target="_blank">{{ article.title|trans }}</a>
              {% endif %}
            </div>
          </td>
          <td>
            {{ admin_macro.user_link(author) }}<br>
            <span class="text-muted">{{review.createdTime|date('Y-n-d H:i')}}</span>
          </td>
          <td>
            {% if review.auditStatus|default('none_checked') == 'pass' %}
              <span class="text-success">{{ '正常'|trans }}</span>
            {% elseif review.auditStatus|default('none_checked') == 'illegal' %}
              <span class="text-danger">{{ '违规'|trans }}</span>
            {% elseif review.auditStatus|default('none_checked') == 'none_checked' %}
              <span class="text-muted">{{ '未审核'|trans }}</span>
            {% endif %}
          </td>
          <td>
            <button class="btn btn-default btn-sm" data-role="item-delete" data-name="{{'admin:operation_article.review.content'|trans}}" data-url="{{ path('admin_v2_article_review_delete', {id:review.id}) }}">{{'form.btn.delete'|trans}}</button>
          </td>
        </tr>
      {% else %}
        <tr><td colspan="20"><div class="empty">{{'site.datagrid.empty'|trans}}</div></td></tr>
      {% endfor %}
      </tbody>
    </table>

    <div>
      <label class="checkbox-inline"><input type="checkbox" data-role="batch-select"> {{'admin.course_thread.select_all_btn'|trans}}</label>
      <button class="btn btn-default btn-sm mlm" data-url="{{ path('admin_v2_article_review_batch_delete') }}" data-role="batch-delete" data-name="{{ 'admin:operation_article.review.content'|trans }}">{{'form.btn.delete'|trans}}</button>
    </div>
  </div>

  {{ admin_macro.paginator(paginator) }}

{% endblock %}